package com.noah.project.controller

import com.noah.project.global.Const
import com.noah.project.model.Company
import org.junit.Test
import org.junit.runner.RunWith
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.junit4.SpringRunner

@RunWith(SpringRunner::class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class CompanyApiControllerTest {
    @Autowired
    lateinit var companyApiController: CompanyApiController

    /*****************日记******************/
    @Test
    @Throws(Exception::class)
    fun addCompany() {
        val company = Company(aid = 1065, position = "gs4", company = "不知道干嘛的4", workStart = 1, workEnd = System.currentTimeMillis())
        val reply = companyApiController.addCompany(company, Const.TEST_TOKEN)
        println(reply.toString())
    }

    @Test
    @Throws(Exception::class)
    fun deleteCompany() {
        val company = Company()
        company.coid = 32
        val reply = companyApiController.deleteCompany(company, Const.TEST_TOKEN)
        println(reply.toString())
    }

    @Test
    @Throws(Exception::class)
    fun deleteCompanyByAid() {
        val company = Company()
        company.aid = 1065
        val reply = companyApiController.deleteCompany(company, Const.TEST_TOKEN)
        println(reply.toString())
    }

    @Test
    @Throws(Exception::class)
    fun updateCompany() {
        val company = Company(coid = 32, position = "内容内容内容", company = "那就算了吧~~~", workStart = 1, workEnd = System.currentTimeMillis())
        val reply = companyApiController.updateCompany(company = company, token = Const.TEST_TOKEN)
        println(reply.toString())
    }

    @Test
    @Throws(Exception::class)
    fun getCompany() {
        val reply = companyApiController.getCompany(coid = 32, token = Const.TEST_TOKEN)
        println(reply.toString())
    }

    @Test
    @Throws(Exception::class)
    fun getAllCompanies() {
        val reply = companyApiController.getCompanyList(aid = 1065)
        println(reply.toString())
    }
}
